<template>
	<div>
		
		<div>
		<van-row>
		  <van-col span="2"></van-col>
		  <van-col span="22">
				<van-row type="flex" justify="space-between" style="height:100px;margin-top:40px">
					<van-col span="8">
						<div style="height: 100%;">
							<img src="https://img.yzcdn.cn/vant/cat.jpeg" style="height:100%;width:100%;border-radius:50%"/> 
						</div>
					</van-col>
					
					<van-col span="15">
						<h2 style="font-size:20px;font-weight:normal;margin-bottom:15px;margin-top:15px">{{this.$store.state.username||token2}}</h2>
						<div>
							<van-button type="primary" size="mini" @click="btn">退出登录</van-button>
							<van-button type="primary" size="mini">开通会员</van-button>
						</div>
					</van-col>
				</van-row>
		  </van-col>
		</van-row>
		
		<van-tabs v-model="active" style="margin-top:30px">
			<van-tab title="我的美食">
				<van-collapse v-model="activeNames">
				  <van-collapse-item title="我的订单" name="1">
						<van-card
						 :num="item.pnum"
						 
						 :price="item.pprice"
						 :desc="item.pname"  
						 :title="item.pname"
						 :thumb="item.pimg"
						  v-for="(item,index) in list" :key='index' style="margin-bottom:30px" ref='btns'>
						<div slot="footer">
						<van-button size="mini" :Bbtn="item.pid" @click='button(index,item.pid)' >删除</van-button>
						 </div>
						</van-card>
				  </van-collapse-item>
				</van-collapse>
			</van-tab>
			
			
		<van-tab title="我的购物车">
			<van-row >
			  <van-col span="22">
				   
				  <van-card
				   :num="item.pnum"
				   
				   :price="item.pprice"
				   :desc="item.pname"  
				   :title="item.pname"
				   :thumb="item.pimg"
				    v-for="(item,index) in list" :key='index' style="margin-bottom:30px" ref='btns'>
					
				  <div slot="footer">
					<input type="checkbox" :v-model="sel" >
				  <van-button size="mini" :Bbtn="item.pid" @click='button(index,item.pid)' >删除</van-button>
				   </div>
				   
				  </van-card>
				  
				  
			  </van-col>
			  
			</van-row>
	
			
			
			
			<van-submit-bar
		  :price="3050"
		  button-text="提交订单"
		  @submit="onSubmit"
		>
		  <van-checkbox v-model="checked" >全选</van-checkbox>
		</van-submit-bar>
		</van-tab>
		
		
		
		<van-tab title="关注">内容 4</van-tab>
		</van-tabs>
		</div>
	</div>
</template>

<script>
	
	import axios from 'axios'
	export default({
		name:'My',
		data(){
			return{
				active:0,
				activeNames: ['1'],
				list:[],
				checked:'',
				sel:'',
				token2:''
			}
		},
		methods:{
			btn(){
				
				
				this.$store.state.username=""
				localStorage.removeItem('token')
				this.$router.push('/home')
			},
			onSubmit(){
				
			},
			
			button(i,pid){
				console.log(pid)
				axios({
					url:'http://jx.xuzhixiang.top/ap/api/cart-delete.php',
					params:{pid,uid:14518}
				}).then((res)=>{
					console.log(res)
					this.list.splice(i,1)
				})
			}
			
			
		},
		mounted(){
			let token = localStorage.getItem("token")
			this.token2=token
			if(!this.$store.state.username&&!token){
				this.$router.push('/login')
			}
			
			
			axios({
				url:'http://jx.xuzhixiang.top/ap/api/cart-list.php',
				params:{id:14518}
			}).then((res)=>{
				console.log(res)
				this.list=res.data.data
				
				
			
				
			})
				 
			
		
			
		},
		
		
	})
	
	
	
</script>

<style>
	*{margin:0;padding:0}
</style>
